import type { ArtColumn } from 'ali-react-table';
import { Button } from 'antd';
import moment from 'moment';

const columns = ({
  showImg,
  goDetails,
}: {
  showImg: (row: any) => void;
  goDetails: (url: string) => void;
}): ArtColumn[] => [
  {
    name: '信息来源',
    code: 'officialAccount',
    width: 140,
    align: 'center',
  },
  {
    name: '发布时间',
    code: 'updateTime',
    align: 'center',
    width: 100,
    render: (value) => moment(value).format('YYYY-MM-DD'),
  },
  {
    name: '文章标题',
    code: 'title',
    align: 'center',
  },
  {
    name: '操作',
    code: 'options',
    align: 'center',
    width: 100,
    render: (_, row) => {
      return (
        <div className="btns">
          <Button type="link" onClick={() => showImg(row)}>
            查看
          </Button>
          <Button type="link" onClick={() => goDetails(row.link)}>
            详情
          </Button>
        </div>
      );
    },
  },
];

export { columns };
